<?php

use common\lib\defaultHtml;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Appoints');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="appoints-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['attribute' => 'appointId', 'value' => function($model){return empty($model->appointId) ? '' : $model->appointId;}],
            ['attribute' => 'appointInteval', 'value' => function($model){return empty($model->appointInteval) ? '' : $model->appointInteval;}],
            ['attribute' => 'appointNo', 'value' => function($model){return empty($model->appointNo) ? '' : $model->appointNo;}],
            ['attribute' => 'useStatus', 'value' => function($model){
                switch($model->useStatus){
                    case 0:return '未使用';break;
                    case 1:return '已核销';break;
                    case 2:return '已延期';break;
                    case 3:return '已过期';break;
                    default:return '未知状态';break;
                } 
            }],
            ['attribute' => 'status', 'value' => function($model){
                switch($model->status){
                    case 0:return '未使用';break;
                    case 1:return '预约成功';break;
                    case 2:return '预约失败';break;
                    default:return '未知状态';break;
                } 
            }],
            ['attribute' => 'changeTimes', 'value' => function($model){return empty($model->changeTimes) ? '' : $model->changeTimes;}],
            ['attribute' => 'created_at', 'value' => function($model){return empty($model->created_at) ? '' : date('Y-m-d H:i:s', $model->created_at);}],
            ['attribute' => 'success_at', 'value' => function($model){return empty($model->success_at) ? '' : date('Y-m-d H:i:s', $model->success_at);}],
            ['attribute' => 'off_at', 'value' => function($model){return empty($model->off_at) ? '' : date('Y-m-d H:i:s', $model->off_at);}],
            //'delay_at',
            //'cancel_at',
            //'error',
            //'appointKey',
            ['attribute' => 'openId', 'value' => function($model){return empty($model->openId) ? '' : $model->openId;}],
            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '<div class="text-center">操作</div>',
                'template' => '<div class="btn-group">{view}</div>',
                'buttons' => [
                    'view' => function ($url, $model, $key) {return defaultHtml::a('<span class="fa fa-eye"></span> 详情', $url, ['title' => '查看详情', 'class' => 'btn btn-xs  btn-success']);},
                ],
                'headerOptions' => ['width' => '120'],
            ],
        ],
    ]); ?>


</div>
